package jwdt.xadmin.bbs.service.impl;

import jwdt.common.dao.BaseDao;
import jwdt.xadmin.bbs.bean.TBboard;
import jwdt.xadmin.bbs.service.BoardManageService;

import com.ezerg.db.ext.PageUtil;

public class BoardManageServiceImpl implements BoardManageService{
	private BaseDao<TBboard> baseDao;
	
	public void setBaseDao(BaseDao<TBboard> baseDao) {
		this.baseDao = baseDao;
	}
	@Override
	public PageUtil doList(PageUtil pu, TBboard l) throws Exception{
		String sql = " order by id desc";
		Integer id = l.getClassid();
		if(id != null && id!=0) {
			sql = "class=" + id + sql;
		}
		pu.doList(TBboard.class,sql);
		//创造json数据对象
		return pu;
	}

	@Override
	public String doSave(TBboard obj,int id) throws Exception {
			if(id==0){
				return baseDao.doAddObj(obj);
			}
			return baseDao.doUpdateObj(TBboard.class, id, obj);
		}
		
	@Override
	public String doDelact(int id) throws Exception {
		return baseDao.doDelObj(TBboard.class, id);
	}

	@Override
	public TBboard doLoad(int id) throws Exception {
		return baseDao.doLoadObj(TBboard.class, id);
	}
	@Override
	public String doUpdateState(int id, String result) throws Exception {
		return baseDao.doIntUpdateState(TBboard.class, "id="+id, result);
	}
}
